#include("/common/_layout.html")
#@layout()
#define layoutHead()
	<link rel="stylesheet" type="text/css" href="/static/other/area/css/city-picker.css">
	<title>机构编辑</title>
	<style>
		.teacher-add{ display: none; }
		.teacher-label{ }
	</style>
#end
#define layoutBody()
	<body>
		<div class="page-content-wrap">
				<form class="layui-form" lay-filter="formedit">
					<input type="hidden" name="org_id">
					<div class="layui-tab" style="margin: 0;">
						<div class="layui-tab-content">
							<div class="layui-tab-item"></div>
							<div class="layui-tab-item layui-show">
								<div class="layui-form-item">
									<label class="layui-form-label">机构名称：</label>
									<div class="layui-input-block">
										<input type="text" name="org_name" required lay-verify="required" placeholder="请输入机构名称" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">机构热线：</label>
									<div class="layui-input-block">
										<input type="text" name="link_tel" required lay-verify="required" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">省/市/县：</label>
									<div class="layui-input-block" id="divapprole">
										<input id="area_id" name="area_id" type="hidden" value="">
										<input id="area_ids" name="area_ids" type="hidden" value="">
										<input type="text" id="area_names" name="area_names" valid="area_id" valids="area_ids" placeholder="点击选择省/市/区/县" value="" readonly data-toggle="city-picker" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">地址：</label>
									<div class="layui-input-block">
										<input type="text" name="area_address" required lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">家长邀请码：</label>
									<div class="layui-input-block">
										<input type="text" name="family_code" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
									</div>
								</div>
								<div class="layui-form-item" style="display: none;">
									<label class="layui-form-label">老师邀请码：</label>
									<div class="layui-input-block">
										<input type="text" name="teacher_code" placeholder="" autocomplete="off" class="layui-input">
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-item" style="padding-left: 10px;">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
							
						</div>
					</div>
				</form>
		</div>
		<script src="/static/other/area/js/city-picker-simple.js"></script>
		<script src="/static/js/jquery.formHelp.js" type="text/javascript" charset="utf-8"></script>
		<script>
	
			layui.use(['form', 'layer', 'laytpl'], function() {
				var form = layui.form();
				var layer = layui.layer;
				var laytpl = layui.laytpl;
				// 表单验证
				form.verify({});

				//监听提交
				form.on('submit(formDemo)', function(formData){
					//console.log(formData.field);
					sendPost("/api/eduorg/org/save", formData.field, function(res) {
						layer.alert(res.msg, {
							title: '信息提示'
						}, function(idx){
							layer.close(idx);
						});
					});
					return false;
				});

				// 页面初始化
				function page_init(){
					var id = getUrlParam('id');

					// 加载初始化编辑数据
					sendGet("/api/eduorg/org/getOrg", {}, function(res) {
						//console.log(res);
						// 初始化编辑数据
						if (res.hasOwnProperty("orginfo")) {
							//console.log(res.orginfo.area_names);
							$("form.layui-form").setForm(res.orginfo);
							$("#area_names").citypicker("refresh");
            
						}
						form.render();
					});
				}

				page_init();
			});
			
			
					
		</script>
	</body>

#end